//
//  KABRCIMMsgListVC.m
//  kabu
//
//  Created by XiangDongMBP on 2017/4/14.
//  Copyright © 2017年 East. All rights reserved.
//

#import "KABRCIMMsgListVC.h"
#import "KABRCIMChatVC.h"

@interface KABRCIMMsgListVC ()

@end

@implementation KABRCIMMsgListVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    [self initNavigationBar];
    [self initSubViews];
}

- (BOOL)hidesBottomBarWhenPushed {
    return YES;
}

- (void)initNavigationBar {
    self.navigationItem.title = @"Kabu IM";
}

- (void)initSubViews {
    [self setDisplayConversationTypes:@[@(ConversationType_PRIVATE)]];
    self.conversationListTableView.tableFooterView = [UIView new];
    
    UIView *custmerView =  [[[NSBundle mainBundle] loadNibNamed:@"KABRCIMMsgListEmpty" owner:self options:nil] firstObject];
    custmerView.frame = [[UIScreen mainScreen] bounds];
    self.emptyConversationView = custmerView;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - delegate
#pragma mark - event response
- (void)onSelectedTableRow:(RCConversationModelType)conversationModelType conversationModel:(RCConversationModel *)model atIndexPath:(NSIndexPath *)indexPath {
    [self jumpToChatView:model];
}

- (void)didDeleteConversationCell:(RCConversationModel *)model {
    [[RCIMClient sharedRCIMClient] deleteMessages:model.conversationType targetId:model.targetId success:nil error:nil];
}

- (void)didTapCellPortrait:(RCConversationModel *)model {
    [self jumpToChatView:model];
}

#pragma mark - private methods
- (void)jumpToChatView:(RCConversationModel *)model {
//    RCConversationViewController *conversationVC = [[RCConversationViewController alloc] init];
    KABRCIMChatVC *conversationVC = [[KABRCIMChatVC alloc] init];
    conversationVC.conversationType = model.conversationType;
    conversationVC.targetId = model.targetId;
    conversationVC.title = model.conversationTitle;
    [self showViewController:conversationVC sender:nil];
}

#pragma mark - network request
#pragma mark - getters and setters

@end
